#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
script name: actress
Created on 2020/2/15 17:59 by PyCharm
@author: fujianjian
"""
from datetime import datetime

from app import db


class Actress(db.Model):
    __tablename__ = 't_actress'
    id = db.Column(db.Integer, primary_key=True, comment='主键')
    name = db.Column(db.String(127), comment='姓名', index=True, nullable=False)
    gender = db.Column(db.Enum('Male', 'Female'), comment='性别')
    birthday = db.Column(db.TIMESTAMP, comment='出生日期')
    measurements = db.Column(db.String(127), comment='个人数据')
    debut_time = db.Column(db.TIMESTAMP, comment='出道时间')
    intro = db.Column(db.String(255), comment='简介')
    product_count = db.Column(db.Integer, default=0, comment='作品数量')
    cup_size = db.Column(db.String(8), comment='cs')
    avatar_uri = db.Column(db.String(64), comment='头像资源')

    created_time = db.Column(db.TIMESTAMP, comment='创建时间', default=True)
    updated_time = db.Column(db.TIMESTAMP, comment='更新时间', default=True)

    def keys(self):
        return ['id','name','gender','birthday','measurements',
                'debut_time','intro','product_count', 'cup_size',
                'avatar_uri', 'created_time', 'updated_time']

    def __getitem__(self, item):
        attr = getattr(self, item)
        if isinstance(attr, datetime):
            attr = attr.strftime('%Y-%m-%d %H:%M:%S')
        return attr

